# -*- coding:utf-8 -*-
# @Time:2024/4/1921:01
# @Author:miuzg
# @FileName:new test2.py
# @Software:PyCharm
import torch.nn as nn

class simplecnn(nn.Module):
    def __init__(self,num_class):  # num_class是我们的分类树
        super().__init__()
        self.feature = nn.Sequential(
            nn.Conv2d(3,16,kernel_size=3,stride=1,padding=1),  # 保持图像大小不变 16*244*244
            nn.ReLU(),  # 卷积之后街上激活函数 增加非线性特征
            nn.MaxPool2d(kernel_size=2,stride=2),  # 池化之后变为16*112*112
            nn.Conv2d(16,32,kernel_size=3,stride=1,padding=1),
            nn.ReLU(),
            nn.MaxPool2D(kernel_size=2,stride=2)  # 图像大小变为23*56*56
        )
        # 定义全连接层 做分类
        self.classifier = nn.Squential(
            nn.Linear(32*56*56,128),
            nn.ReLU(),
            nn.Linear(128,num_class)  # num_class为分类的个数
        )
    def forward(self,x):
        # 前向传播部分
        x = self.features(x)  # 先将特征及逆行特征提取
        x.view(x.size(0),-1)  
        x = self.classifier(x)